package Tree;

import java.util.ArrayList;
import java.util.List;

public class _589_N_aryTreePreorderTraversal {
    List<Integer> res = new ArrayList<>();
    public List<Integer> preorder(Node root) {
        preorderTraversal(root);
        return res;
    }

    public void preorderTraversal(Node root) {
        if (root != null) {
            res.add(root.val);
            for (Node node : root.children) {
                preorderTraversal(node);
            }
        }
    }
}
